package com.atguigu.gulimall.cart.config;

import com.atguigu.gulimall.cart.interceptor.CartInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description :
 * @Author : mayp
 * @Date: 2020-11-30 17:43
 */
@Configuration
public class GulimallWebConfig implements WebMvcConfigurer {
    /**
     * 添加拦截器，主要给拦截器生效，拦截购物车的所有请求。也就是说购物车的所有请求都必须要有账号，临时或已登录
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new CartInterceptor()).addPathPatterns("/**"); // 拦截当前购物车全部请求
    }
}
